using System;
using UnityEngine;
using UnityEngine.UI;

public class UIAIPlayerItem : MonoBehaviour
{
	public Image headerIcon;

	public Image bgImg;

	public new Text name;

	public Text chips;

	public Text chipsLbl;

	public Text fee;

	public Action<BattleInfo> onClick;

	public Image lockImg;

	public Image chipIcon1;

	public Image chipIcon2;

	private RectTransform m_Trans;

	private Vector3 m_ScaleVector;

	private float m_Distance;

	public BattleInfo battleInfo
	{
		get;
		set;
	}

	public ScrollRect scrollRect
	{
		get;
		set;
	}

	private void Start()
	{
		m_Trans = (base.transform as RectTransform);
		scrollRect.onValueChanged.AddListener(OnScrollValueChange);
		m_ScaleVector = Vector3.one * 1.3f;
		m_ScaleVector.z = 1f;
		m_Distance = 5f;
	}

	private void Update()
	{
	}

	private void OnDestroy()
	{
		scrollRect.onValueChanged.RemoveListener(OnScrollValueChange);
	}

	public void SetFee(int fee)
	{
		this.fee.text = "费用:" + fee;
	}

	public void OnClick()
	{
		UnityEngine.Debug.Log("click level");
		if (onClick != null && battleInfo != null)
		{
			if (BattleInfoMgr.IsLock(battleInfo.id))
			{
				TopBarTip.Show(395);
			}
			else
			{
				onClick(battleInfo);
			}
		}
	}

	public void Unlock()
	{
		lockImg.gameObject.SetActive(value: false);
		bgImg.color = Color.white;
		headerIcon.color = Color.white;
		Gradient component = chips.gameObject.GetComponent<Gradient>();
		component.topColor = new Color32(byte.MaxValue, byte.MaxValue, 47, byte.MaxValue);
		component.bottomColor = new Color32(238, 94, 0, byte.MaxValue);
		chips.gameObject.GetComponent<CircleOutline>().effectColor = new Color(146f / 255f, 7f / 85f, 0f, 0.5f);
		chipIcon1.color = Color.white;
		chipIcon2.color = Color.white;
		chipsLbl.color = Color.white;
		fee.color = Color.white;
	}

	public void Lock()
	{
		lockImg.gameObject.SetActive(value: true);
		bgImg.color = Color.gray;
		headerIcon.color = Color.gray;
		Gradient component = chips.gameObject.GetComponent<Gradient>();
		component.topColor = new Color32(96, 96, 96, byte.MaxValue);
		component.bottomColor = new Color32(28, 28, 28, byte.MaxValue);
		chips.gameObject.GetComponent<CircleOutline>().effectColor = new Color(23f / 255f, 23f / 255f, 23f / 255f, 1f);
		chipIcon1.color = Color.gray;
		chipIcon2.color = Color.gray;
		chipsLbl.color = new Color(58f / 255f, 58f / 255f, 58f / 255f, 1f);
		fee.color = new Color(58f / 255f, 58f / 255f, 58f / 255f, 1f);
	}

	public void OnScrollValueChange(Vector2 value)
	{
		RectTransform trans = m_Trans;
		Vector3 scaleVector = m_ScaleVector;
		Vector3 one = Vector3.one;
		Vector3 position = m_Trans.position;
		trans.localScale = Vector3.Lerp(scaleVector, one, Mathf.Abs(position.x / m_Distance));
	}
}
